package com.fansl.koala.quickdev.common.exception;

import com.fansl.koala.quickdev.common.enums.ResultEnum;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author fansl
 * @Description: 自定义业务异常
 * @date 2020/3/12 11:40
 */
@NoArgsConstructor
public class BizException extends RuntimeException {

    @Getter
    @Setter
    private int code = 1000;

    public BizException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BizException(ResultEnum result) {
        super(result.getMessage());
        this.code = result.getCode();
    }

    public BizException(String message) {
        super(message);
    }

    public BizException(Throwable cause) {
        super(cause);
    }

    public BizException(String message, Throwable cause) {
        super(message, cause);
    }

    public BizException(String message, Throwable cause,
                        boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }
}
